package org.yang.snake.aop;


import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.yang.snake.annotation.SnakeLog;

/**
 * 日志切面
 *
 * @author shichenyang
 */
@Aspect
@Component
@Slf4j
public class LogAop {
    /**
     * 增强方法
     * @param point 连接点，能够获取切面的一些信息
     * @return
     */
    @Around("@annotation(snakeLog)")
    @SneakyThrows
    public Object around(ProceedingJoinPoint point, SnakeLog snakeLog) {
        String strClassName = point.getTarget().getClass().getName();
        String strMethodName = point.getSignature().getName();
        log.debug("[类名]:{},[方法]:{},日志:{}", strClassName, strMethodName,snakeLog.value());
        Object obj = point.proceed();
        return obj;
    }

}
